package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.MessageHistory;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.service.IMessageHistoryService;
import cn.wolfcode.crm.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("messageHistory")
public class MessageHistoryController {
    @Autowired
    private IMessageHistoryService messageHistoryService;
    @ResponseBody
    @RequestMapping("selectAll")
    public Object selectAll(){
        List<MessageHistory> messageHistories = messageHistoryService.selectAll();
        return messageHistories;
    }
    @RequestMapping("save")
    @ResponseBody
    public JSONResult save(MessageHistory entity){
        try {
            messageHistoryService.saveOrUpdate(entity);
            return JSONResult.success("保存成功");
        }catch(Exception e){
            e.printStackTrace();
            return JSONResult.mark("保存失败");
        }
    }
}
